using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ObviousCode.Stately;
using ICSharpCode.NRefactory.CSharp;
using ObviousCode.Stately.Compiler.Validation.Expectations;

namespace ObviousCode.Stately.Compiler.Validation
{
	public partial class DefinedTransitionValidator
	{		   
		public void Validate(BlockStatement statement, DefinedStateTransition definedTransition, ExpectationValidatorContext validatorContext, Action<DefindedTransitionValidationContext> callback)
		{
			DefindedTransitionValidationContext context = new DefindedTransitionValidationContext();

			context.Callback = callback;
            context.Statement = statement;
            context.DefinedTransition = definedTransition;
            context.ValidatorContext = validatorContext;

			_stately.Start(Step.AscertainTransitionType, context);
		}

		private ITransitionRequest HandleAscertainTransitionType(DefindedTransitionValidationContext context)
		{
            if (context.DefinedTransition.Source.IsStartState)
            {
                return _stately.T(Step.ValidateStart, context);
            }
            else
            {
                return _stately.T(Step.ValidateStepTransition, context);
            }			
		}

        private ITransitionRequest HandleValidateStart(DefindedTransitionValidationContext context)
        {
            return _stately.T(Step.WarnIfReturnTypeNotVoid, context);           
        }

        private ITransitionRequest HandleValidateStepTransition(DefindedTransitionValidationContext context)
        {
            return _stately.T(Step.ErrorIfReturnTypeNotITransitionRequest, context);
        }

        private ITransitionRequest HandleWarnIfReturnTypeNotVoid(DefindedTransitionValidationContext context)
        {
            //return _stately.T(Step.AssertInvocations, context);

            throw new NotImplementedException();

        }

        private ITransitionRequest HandleAssertInvocations(DefindedTransitionValidationContext context)
        {
            //return _stately.T(Step.Complete, context);

            throw new NotImplementedException();

        }

        private ITransitionRequest HandleErrorIfReturnTypeNotITransitionRequest(DefindedTransitionValidationContext context)
        {
            //return _stately.T(Step.AssertInvocations, context);

            throw new NotImplementedException();

        }

        private ITransitionRequest HandleComplete(DefindedTransitionValidationContext context)
        {
            //return CompleteRequest.Instance

            throw new NotImplementedException();

        }


	}
}

